/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Main;

import java.util.*;

/**
 *
 * @author bryan
 */
public class Agent {
    private String name;
    private HashMap<Interaction,Integer> motivationMap;
    private Trace trace;
    
    /**
     * Constructor
     * @param _name 
     */
    public Agent(String _name){
        name = _name;
        motivationMap = new HashMap<>();
        trace = new Trace();
    }
    
    /**
     * Put a couple of interactionName and MotivationValue
     * @param interaction
     * @param value 
     */
    public void putInteraction(Interaction interaction, Integer value){
        motivationMap.put(interaction,value);
    }

    /**
     * Get previous interaction result compare to the previus step
     * @param _prevInteraction
     * @return the _prevInteraction
     */
    public Interaction step(Interaction _prevInteraction){
        return _prevInteraction;
    }

    /**
     * Get the best benefit from motivations
     * @return the bestInteraction
     */
    public Interaction getBest(){
        Integer max = Integer.MIN_VALUE;
        Interaction interaction = new Interaction("");
        for (Map.Entry<Interaction, Integer> entry : motivationMap.entrySet()) {
            if(entry.getValue() > max)
                interaction = entry.getKey();
        }
        return interaction;
    }
    
    /**
     * Getter name
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * Setter name
     * @param _name the name to set
     */
    public void setName(String _name) {
        this.name = _name;
    }
}
